package com.web.portal.utils;


import java.util.Date;
import java.util.Random;

public class CodeUtils {
    public CodeUtils() {
    }

    public static String getOrderCode(int n) {
        String orderCode = "";
        long time = (new Date()).getTime();
        orderCode = orderCode + time;
        orderCode = orderCode + makeRandom(n);
        return orderCode;
    }

    public static String getSmsCode(int n) {
        String code = "";
        code = code + makeRandom(n);
        return code;
    }

    private static String makeRandom(int n) {
        String ranCode = "";
        Random ran = new Random();

        for(int i = 0; i < n; ++i) {
            ranCode = ranCode + ran.nextInt(9);
        }

        return ranCode;
    }
}
